function ct() {
    return document.compatMode == "BackCompat" ? document.body.clientHeight : document.documentElement.clientHeight;
}
(window.onresize = function() {
    var position = document.body.scrollHeight > ct() ? '' : 'absolute';
    $('footer').css('position', position);
})();
var timer;
$(document).ready(function() {
    if ($('.chat').css('display') == 'none') {
        $('.chat').css('display', 'block');
    }
    $(window).on('scroll');
    timer = setInterval(animate, 1000);
});
//方块移动动画实现
var left = 0,
    y = 0,
    flag = false;

function animate() {
    //                var left=$('.meeting').css('left');
    //                var top=$('.meeting').css('top');

    console.log('left:' + left + ' top:' + y);
    console.log(window.innerWidth + ";" + window.innerHeight);
    var perent = window.innerHeight / window.innerWidth;
    if (left < body(window.innerWidth - $('.meeting').width()) - 10) {
        left += 100;
    } else {
        left = 0;
        y = 0;
        flag = false;
        $('.meeting').css({
            'left': left + 'px',
            'top': y + 'px'
        });
        //                    raf(animate);
        return false;
    }
    if (y < (window.innerHeight - $('.meeting').height()) / 2 && flag == false) {
        y += 100 * perent;
    } else {
        y -= 100 * perent;
        flag = true;
    }
    $('.meeting').animate({
        'left': left + 'px',
        'top': y + 'px'
    }, 100);
    //                raf(animate);
}
//移动小方块在鼠标进入的时候停止，在鼠标离开的时候继续移动
$(function() {
    $('.meeting').mouseover(function() {
        clearInterval(timer);
    });
    $('.meeting').mouseout(() => {
        timer = setInterval(animate, 1000);
    });
});

//动画频率
var raf = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
    window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) {
        window.setTimeout(callback, 1000 / 60);
    };
//在页面滚动下滑的时候显示返回顶部按钮
$(window).scroll(function() {
    var scHeight = $(window).scrollTop();
    var width = $(window).height();
    if (scHeight > 100) {
        //                    $('.back').css('display','block');
        //增加渐隐渐现的效果
        $('.back').fadeIn(1500);
    } else {
        //                    $('.back').css('display','none');
        $('.back').fadeOut(1500);
    }
});
$('.back').click(function() {
    //                var scHeight=$(window).scrollTop();
    $('body,html').animate({
        scrollTop: 0
    }, 300);
    return false;
});
//根据鼠标进入和离开显示天气信息
$('.show_weather').mouseover(function(e) {
    var timer1 = setTimeout(() => {
        $('.weather-box').fadeIn(1000);
        $('.show_weather').animate({
            'left': '-50px'
        }, 500);
    }, 500);

    //                var left= e.clientX+10;
    //                var top=$(window).height()- e.clientY;
    //                $('.weather-box').css({'left':left,'top': top});
});
$('.weather-box').mouseleave(function() {
    var timer2 = setTimeout(() => {
        $('.weather-box').fadeOut(1000);
        $('.show_weather').animate({
            'left': '10px'
        }, 500);
    }, 500);
    //                $('.weather-box').fadeOut(1000);
    //                $('.show_weather').fadeIn(1000);
    //                $('.show_weather').animate({'left':'10px'},500);
});